/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "iva", catalog = "corporate", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Iva.findAll", query = "SELECT i FROM Iva i"),
    @NamedQuery(name = "Iva.findByIdIva", query = "SELECT i FROM Iva i WHERE i.idIva = :idIva"),
    @NamedQuery(name = "Iva.findByPaisYD", query = "SELECT i FROM Iva i WHERE i.pais.idPais = :idPais and I.d.idD = :idD"),
    @NamedQuery(name = "Iva.findByIva", query = "SELECT i FROM Iva i WHERE i.iva = :iva")})
public class Iva implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_IVA")
    private Integer idIva;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "IVA")
    private BigDecimal iva;
    @JoinColumn(name = "PAIS", referencedColumnName = "ID_PAIS")
    @ManyToOne(optional = false)
    private Pais pais;
    @JoinColumn(name = "D", referencedColumnName = "ID_D")
    @ManyToOne(optional = false)
    private D d;

    public Iva() {
    }

    public Iva(Integer idIva) {
        this.idIva = idIva;
    }

    public Iva(Integer idIva, BigDecimal iva) {
        this.idIva = idIva;
        this.iva = iva;
    }

    public Integer getIdIva() {
        return idIva;
    }

    public void setIdIva(Integer idIva) {
        this.idIva = idIva;
    }

    public BigDecimal getIva() {
        return iva;
    }

    public void setIva(BigDecimal iva) {
        this.iva = iva;
    }

    public Pais getPais() {
        return pais;
    }

    public void setPais(Pais pais) {
        this.pais = pais;
    }

    public D getD() {
        return d;
    }

    public void setD(D d) {
        this.d = d;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idIva != null ? idIva.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Iva)) {
            return false;
        }
        Iva other = (Iva) object;
        if ((this.idIva == null && other.idIva != null) || (this.idIva != null && !this.idIva.equals(other.idIva))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Iva[ idIva=" + idIva + " ]";
    }
    
}
